<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page   import="java.util.List"%>
<%@ page   import="grupobbva.pe.operhc.domain.SegUsuario"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/ui.jqgrid.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/redmond/jquery-ui-1.8.2.custom.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/operhc_style.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/buttonOHC.css" />

	<script src="<%=request.getContextPath()%>/js/util/gridUtil.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery-1.7.1.js" type="text/javascript"></script>	
	<script src="<%=request.getContextPath()%>/js/i18n/grid.locale-es.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery.jqGrid.src.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/grid.subgrid.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/util/encabezado.js" type="text/javascript"></script>

<title>Formulario de Parametro</title>

</head>

<%
SegUsuario usuarioSession = (SegUsuario)request.getSession().getAttribute("usuarioSession");
if(!"1".equals(usuarioSession.getAdmin())){ 
response.sendRedirect("operativizacion.jsp");
}
%>

<body>

<html:form method="post" action="mantenimientoParametro.do?method=guardar" styleId="formParametro">
<html:hidden property="stNew" styleId="stNew"/>

	<div style="background-color: #0066bb;">
		<font face="Arial Narrow" size=3 color="#FFFFFF"><b>&nbsp;<bean:message key="etiqueta.titleManteUsuario"/></b></font>
	</div>
	
	<br/>

	<table align="center">
		
		<tr>
			<td align="right" valign="middle">
				Código de Parámetro :
			</td>
			<td align="left" valign="middle">
				<html:text property="codParametro" styleId="codParametro" style="width: 150px" maxlength="250"/>
				<html:hidden property="codParametroHdn" styleId="codParametroHdn" style="width: 150px"/>				
			</td>
		</tr>
	
		<tr>
			<td align="right" valign="middle">
				Descripción de Parámetro :
			</td>
			<td align="left" valign="middle">
				<html:text property="desParametro" styleId="desParametro" style="width: 150px" maxlength="250"/>				
			</td>
		</tr>

		<tr>
			<td align="right" valign="middle">
				Valor de Parámetro :
			</td>
			<td align="left" valign="middle">
				<html:text property="valParametro" styleId="valParametro" style="width: 150px" maxlength="250"/>				
			</td>
		</tr>
		
		<tr>
			<td align="right" valign="middle">
				Código Parámetro Host :
			</td>
			<td align="left" valign="middle">
				<html:text property="codParamHost" styleId="codParamHost" style="width: 150px" maxlength="2"/>				
			</td>
		</tr>
		
		<tr>
			<td align="right" valign="middle">
				Orden Parámetro :
			</td>
			<td align="left" valign="middle">
				<html:text property="ordValParametro" onkeypress="validarNumeros(event, this);" styleId="ordValParametro" style="width: 150px" maxlength="255"/>				
			</td>
		</tr>
        
        <tr><td>&nbsp;</td></tr>
        <tr><td align="center" valign="middle" colspan="3">
        
        <%--
        <html:button property="btnGuardar" value="Guardar" onclick="validacionForm('guardar')" />&nbsp;&nbsp;
        <html:button property="btnCancelar" value="Cancelar" onclick="validacionForm('cancelar')" />
         --%>
         
        <a href="#" onclick="validacionForm('guardar');" class="buttonOHC">GUARDAR</a>&nbsp;&nbsp;
        <a href="#" onclick="validacionForm('cancelar');" class="buttonOHC">CANCELAR</a>
        
        </td></tr>
        
	</table>

</html:form>
</body>
<script type="text/javascript">

var rutaContexto1 = location.pathname;
var rutaContexto2 = "<%=request.getContextPath()%>";
var rutaContexto  = rutaContexto1.substr(0, rutaContexto1.indexOf(rutaContexto2)) + rutaContexto2;

function validacionForm(operacion){
	
	if(operacion == 'guardar'){
		
		var codigoParametro = document.forms[0].codParametro.value;
		var ordValParametro = document.forms[0].ordValParametro.value;
		
		if(codigoParametro == ''){
			alert('El codigo del parametro es obligatorio');
			return false;
		}
		
    	var patron = /\d/; 
        var isValid = patron.test(ordValParametro);
        if(!isValid){
        	document.forms[0].ordValParametro.value = '';
        }

		document.forms[0].action = rutaContexto+'/mantenimientoParametro.do?method=guardar';
		document.forms[0].submit();
		
	}else{
		
		document.forms[0].action = rutaContexto+'/mantenimientoParametro.do?method=verListado';
		document.forms[0].submit();
	}
}

</script>
</html>